package com.s3.khospitalds.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.s3.khospitalds.common.R;
import com.s3.khospitalds.common.ResponseEntity;
import com.s3.khospitalds.entity.Doctor;
import com.s3.khospitalds.entity.Staffintroduction;
import com.s3.khospitalds.mapper.EmployeeintroductionMapper;
import com.s3.khospitalds.service.EmployeeintroductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hlq
 * @version 1.0
 * @Description
 * @date 2025/2/20 10:34
 */
@Service
public class EmployeeintroductionServiceImpl extends ServiceImpl<EmployeeintroductionMapper, Staffintroduction> implements EmployeeintroductionService{
    @Autowired
    EmployeeintroductionMapper employeeintroductionMapper;
    @Autowired
    EmployeeintroductionServiceImpl employeeintroductionServiceImpl;

    @Override
    public List<Staffintroduction> IntroduceAll(String profession){
        return employeeintroductionMapper.IntroduceAll(profession);
    }

    @Override
    public List<Staffintroduction> NurseAll(String profession) {
        return employeeintroductionMapper.NurseAll(profession);
    }

    @Override
    public ResponseEntity selectByProfession(int pageNum, int pageSize,String department, String special, String position) {
        ResponseEntity responseEntity = new ResponseEntity();
        //模糊查询
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("profession", "医生");
        if(department!=null&&!department.equals("")){
            queryWrapper.like("department",department);
            System.out.println("\ndepartment = " + department + "\n");
        }
        if (special!=null&&!special.equals("")) {
            queryWrapper.like("special",special);
            System.out.println("\nspecial = " + special + "\n");
        }
        if (position != null&&!position.equals("")){
            queryWrapper.like("position",position);
            System.out.println("\nposition = " + position + "\n");
        }
        //使用分页查询
        List<Staffintroduction> sta = employeeintroductionServiceImpl.list(queryWrapper);
        //创建分页的对象
        PageInfo<Staffintroduction> pageInfo = new PageInfo<>(sta);
        //设置响应对象的行数据
        responseEntity.setData(pageInfo.getList());
        return responseEntity;
    }

    @Override
    public ResponseEntity selNurse(int pageNum, int pageSize, String department, String name, String area) {
        ResponseEntity responseEntity = new ResponseEntity();
        //模糊查询
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("profession", "护士");
        if(department!=null&&!department.equals("")){
            queryWrapper.like("department",department);
            System.out.println("\ndepartment = " + department + "\n");
        }
        if (name!=null&&!name.equals("")) {
            queryWrapper.like("name",name);

        }
        if (area != null&&!area.equals("")){
            queryWrapper.like("area",area);
            System.out.println("\narea = " + area + "\n");
        }
        //使用分页查询
        List<Staffintroduction> nurse = employeeintroductionServiceImpl.list(queryWrapper);
        //创建分页的对象
        PageInfo<Staffintroduction> pageInfo = new PageInfo<>(nurse);
        //设置响应对象的行数据
        responseEntity.setData(pageInfo.getList());
        return responseEntity;
    }


}
